#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
using namespace std;
#define int long long
int ans(int x)
{
    int res = 1;
    for (int i = 2;i <= x / i;i++)
    {
        if (x % i == 0)
        {
            int s = 0;
            while (x % i == 0)
                s++, x /= i;
            res = res * (s + 1);
        }
    }
    if (x > 1)
        res *= 2;
    return res;
}
signed main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int a, b;
        cin >> a >> b;
        cout << ans(a * b) << '\n';
    }
    return 0;
}